<template>
	<view>
		<view v-for="(el,i) in data" :key="i"
			:class="{
				'pb-3-1': i === data.length - 1,
				'pt-3-1': i > 0 || (i === 0 && firstHasPt),
				'px-3-1': hasPx
			}" 
			@click="click(el)">
			<view class='text-hide mb-1'>
				<image class='w-full block' :src="el.src"></image>
			</view>
			<view class='mb-1'>
				<text class="text-n text-ellipsis-1" style="width: 224px">{{el.title}}</text>
			</view>
			<view class='color-secondary-3 flex flex-row text-s'>
				<text>{{el.label}}</text>
				<text class='flex-1 text-center'>{{el.type}}</text>
				<text>{{el.date}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			data: Array,
			//第一项是否有padding-top
			firstHasPt: Boolean,
			//每一项是否有padding-left padding-right
			hasPx: Boolean
		},
		name:"ArticleList",
		setup(){
			function click(el){
				uni.navigateTo({
					url: "/pages/article-detail/article-detail",
					success: function(res) {
						res.eventChannel.emit('data', { ...el })
					}
				})
			}
			return {
				click
			};
		}
	}
</script>

<style>

</style>
